using System.Collections.Generic;
using System.IO;

namespace BLGenerator.BusinessLogic.FileGenerators
{
    class CompositeFileBlock : List<IFileBlock>, IFileBlock
    {
        public void Add()
        {
            this.Add(string.Empty);
        }

        public void Add(string str)
        {
            this.Add(new StringFileBlock(str));
        }

        public void Add(int numTabs, string str)
        {
            this.Add(new StringFileBlock(FileGeneratorsHelper.TabsToString(numTabs) + str));
        }

        public void WriteToStream(StreamWriter stream)
        {
            WriteToStream(stream, -1);
        }

        public void WriteToStream(StreamWriter stream, int tabNums)
        {
            foreach (IFileBlock block in this)
            {
                block.WriteToStream(stream, tabNums + 1);
            }
        }
    }
}